<html>
<head><meta charset="utf-8"><title>slow? · t-compiler/rust-analyzer · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/index.html">t-compiler/rust-analyzer</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/slow.3F.html">slow?</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="188401583"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/slow%3F/near/188401583" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/slow.3F.html#188401583">(Feb 17 2020 at 19:25)</a>:</h4>
<p>Just checking, is this normal?</p>
<div class="codehilite"><pre><span></span> 1120ms - LibraryData::prepare
 1372ms - LibraryData::prepare
 1469ms - LibraryData::prepare
 1507ms - LibraryData::prepare
 1685ms - LibraryData::prepare
 2510ms - LibraryData::prepare
 1023ms - LibraryData::prepare
 1497ms - LibraryData::prepare
 1604ms - LibraryData::prepare
 2241ms - LibraryData::prepare
 2281ms - LibraryData::prepare
 3578ms - LibraryData::prepare
 2320ms - LibraryData::prepare
 4202ms - LibraryData::prepare
 1034ms - LibraryData::prepare
 1654ms - LibraryData::prepare
 4652ms - LibraryData::prepare
 1665ms - LibraryData::prepare
 4398ms - LibraryData::prepare
 1685ms - LibraryData::prepare
 2008ms - LibraryData::prepare
57160ms - handle_code_action
    57160ms - diagnostics
        27521ms - SourceBinder::to_module_def
            27521ms - crate_def_map
                27521ms - compute_crate_def_map
                     1978ms - crate_def_map
                         1973ms - compute_crate_def_map
                                5ms - enum_data_query (7 calls)
                             1937ms - raw_items_query (3900 calls)
                            4ms - parse_query (1 calls)
                     4937ms - crate_def_map
                         4937ms - compute_crate_def_map
                             4879ms - crate_def_map
                                 4879ms - compute_crate_def_map
                                     4844ms - crate_def_map
                                         4844ms - compute_crate_def_map
                                                5ms - crate_def_map (11827 calls)
                                             4364ms - raw_items_query (11810 calls)
                                        0ms - crate_def_map (7 calls)
                                        1ms - raw_items_query (1 calls)
                               51ms - crate_def_map (29 calls)
                                0ms - enum_data_query (1 calls)
                                6ms - raw_items_query (17 calls)
                     1250ms - crate_def_map
                         1250ms - compute_crate_def_map
                             1223ms - crate_def_map
                                 1223ms - compute_crate_def_map
                                     1049ms - crate_def_map
                                         1049ms - compute_crate_def_map
                                             1033ms - crate_def_map (199 calls)
                                                0ms - enum_data_query (1 calls)
                                               15ms - raw_items_query (39 calls)
                                       19ms - crate_def_map (429 calls)
                                        0ms - enum_data_query (3 calls)
                                      150ms - raw_items_query (137 calls)
                                0ms - crate_def_map (81 calls)
                               26ms - raw_items_query (28 calls)
                     3057ms - crate_def_map
                         3057ms - compute_crate_def_map
                             2389ms - crate_def_map
                                 2389ms - compute_crate_def_map
                                     2333ms - crate_def_map
                                         2333ms - compute_crate_def_map
                                             2267ms - crate_def_map
                                                 2267ms - compute_crate_def_map
                                                     1851ms - crate_def_map
                                                         1851ms - compute_crate_def_map
                                                                1ms - crate_def_map (4021 calls)
                                                             1783ms - raw_items_query (4014 calls)
                                                      388ms - crate_def_map (153 calls)
                                                       27ms - raw_items_query (52 calls)
                                               25ms - crate_def_map (226 calls)
                                               39ms - raw_items_query (32 calls)
                                       37ms - crate_def_map (125 calls)
                                       18ms - raw_items_query (27 calls)
                               88ms - crate_def_map (1475 calls)
                                0ms - enum_data_query (1 calls)
                              556ms - raw_items_query (1271 calls)
                     2727ms - crate_def_map
                         2727ms - compute_crate_def_map
                             2644ms - crate_def_map (311 calls)
                                0ms - enum_data_query (1 calls)
                               81ms - raw_items_query (102 calls)
                     1508ms - crate_def_map
                         1508ms - compute_crate_def_map
                             1229ms - crate_def_map (514 calls)
                                0ms - enum_data_query (6 calls)
                              274ms - raw_items_query (233 calls)
                     4739ms - crate_def_map
                         4739ms - compute_crate_def_map
                             1489ms - crate_def_map
                                 1489ms - compute_crate_def_map
                                     1296ms - crate_def_map (701 calls)
                                        0ms - enum_data_query (1 calls)
                                      188ms - raw_items_query (185 calls)
                             3168ms - crate_def_map (338 calls)
                               79ms - raw_items_query (52 calls)
                     1219ms - crate_def_map
                         1219ms - compute_crate_def_map
                             1083ms - crate_def_map (485 calls)
                                0ms - enum_data_query (5 calls)
                              132ms - raw_items_query (172 calls)
                     1239ms - crate_def_map
                         1239ms - compute_crate_def_map
                             1123ms - crate_def_map (1133 calls)
                              111ms - raw_items_query (187 calls)
                     4581ms - crate_def_map (2064 calls)
                      270ms - raw_items_query (918 calls)
        29637ms - Module::diagnostics
            26839ms - Module::diagnostics
                23858ms - Function::diagnostics
                    23858ms - infer
                        23858ms - do_infer
                             1715ms - impls_in_crate_query
                                    3ms - crate_def_map (19472 calls)
                                 1361ms - parse_macro_query (5080 calls)
                                   88ms - parse_query (28 calls)
                             2524ms - impls_in_crate_query
                                   14ms - crate_def_map (80562 calls)
                                 2133ms - parse_macro_query (9637 calls)
                             1078ms - impls_in_crate_query
                                    4ms - crate_def_map (23053 calls)
                                  941ms - parse_macro_query (2471 calls)
                             1475ms - impls_in_crate_query
                                    1ms - crate_def_map (5371 calls)
                                 1335ms - parse_macro_query (2995 calls)
                                   33ms - parse_query (23 calls)
                             1296ms - trait_solve_query
                                    0ms - crate_def_map (1184 calls)
                                 1276ms - impl_datum (601 calls)
                                    3ms - parse_query (1 calls)
                                0ms - body_with_source_map_query (1 calls)
                                0ms - crate_def_map (299 calls)
                            13755ms - impls_in_crate_query (348 calls)
                             1055ms - parse_macro_query (3115 calls)
                              384ms - parse_query (102 calls)
                              441ms - trait_solve_query (16 calls)
                 1265ms - Function::diagnostics
                     1265ms - infer
                         1265ms - do_infer
                             1263ms - trait_solve_query
                                    0ms - crate_def_map (1 calls)
                                 1257ms - impl_datum (446 calls)
                                0ms - body_with_source_map_query (1 calls)
                                0ms - crate_def_map (23 calls)
                                2ms - trait_solve_query (6 calls)
                 1715ms - Function::diagnostics (4 calls)
                    0ms - crate_def_map (3 calls)
             2746ms - Function::diagnostics
                 2746ms - infer
                     2746ms - do_infer
                         1479ms - trait_solve_query
                                0ms - crate_def_map (1402 calls)
                              169ms - impl_datum (5891 calls)
                               20ms - parse_macro_query (13 calls)
                             1144ms - parse_query (191 calls)
                            4ms - body_with_source_map_query (1 calls)
                            0ms - crate_def_map (392 calls)
                            1ms - parse_macro_query (4 calls)
                           21ms - parse_query (6 calls)
                         1233ms - trait_solve_query (40 calls)
                8ms - Function::diagnostics (1 calls)
               42ms - Module::diagnostics (1 calls)
                0ms - crate_def_map (3 calls)
        0ms - SourceBinder::analyzer (1 calls)
        0ms - add_missing_impl_members_inner (2 calls)
</pre></div>



<a name="188401971"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/slow%3F/near/188401971" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/slow.3F.html#188401971">(Feb 17 2020 at 19:32)</a>:</h4>
<p>I got another one, with <code>inlay_hints</code> taking 55s: <a href="https://gist.github.com/lnicola/1ff7a8e195a82b848517f2d483c77e1f" target="_blank" title="https://gist.github.com/lnicola/1ff7a8e195a82b848517f2d483c77e1f">https://gist.github.com/lnicola/1ff7a8e195a82b848517f2d483c77e1f</a>. I guess that's fine? But why are they called so many times?</p>



<a name="188402261"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/slow%3F/near/188402261" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/slow.3F.html#188402261">(Feb 17 2020 at 19:38)</a>:</h4>
<p>That's the first call, right?</p>



<a name="188402344"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/slow%3F/near/188402344" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/slow.3F.html#188402344">(Feb 17 2020 at 19:39)</a>:</h4>
<p>Yup</p>



<a name="188402413"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/slow%3F/near/188402413" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/slow.3F.html#188402413">(Feb 17 2020 at 19:40)</a>:</h4>
<p>For context: <a href="https://github.com/rust-analyzer/rust-analyzer/issues/3057#issuecomment-587122420" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/issues/3057#issuecomment-587122420">https://github.com/rust-analyzer/rust-analyzer/issues/3057#issuecomment-587122420</a>. The gist is from the 75 s run.</p>



<a name="188402435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/slow%3F/near/188402435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/slow.3F.html#188402435">(Feb 17 2020 at 19:40)</a>:</h4>
<p>I guess in general this is expected, but <code>4364ms - raw_items_query (11810 calls)</code> does seem odd -- that's 11k files/module-level macros</p>



<a name="188402528"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/slow%3F/near/188402528" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/slow.3F.html#188402528">(Feb 17 2020 at 19:42)</a>:</h4>
<p>The project uses Rocket, so there might be a lot of them, but 11k seems large.</p>



<a name="188402551"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/slow%3F/near/188402551" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/slow.3F.html#188402551">(Feb 17 2020 at 19:42)</a>:</h4>
<p>And why the 30? <code>rust-analyzer/inlayHints</code> requests on a single file?</p>



<a name="188402731"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/slow%3F/near/188402731" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/slow.3F.html#188402731">(Feb 17 2020 at 19:46)</a>:</h4>
<p>Stupid question: should <a href="https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/inlay_hints.rs#L35" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/inlay_hints.rs#L35">https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide/src/inlay_hints.rs#L35</a> be using <code>descendants</code> here?</p>



<a name="188402810"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/slow%3F/near/188402810" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/slow.3F.html#188402810">(Feb 17 2020 at 19:48)</a>:</h4>
<p>Yep, it should, because we want to visit every node</p>



<a name="188402828"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/slow%3F/near/188402828" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/slow.3F.html#188402828">(Feb 17 2020 at 19:48)</a>:</h4>
<p>Won't it visit nodes multiple times?</p>



<a name="188402834"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/slow%3F/near/188402834" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/slow.3F.html#188402834">(Feb 17 2020 at 19:48)</a>:</h4>
<p>it probably makes sense to put the profile call to a more reasonable place though -- it doesn't really make sense to count how many times are we calculating hints for every semicolon</p>



<a name="188402865"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/slow%3F/near/188402865" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> matklad <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/slow.3F.html#188402865">(Feb 17 2020 at 19:49)</a>:</h4>
<blockquote>
<p>Won't it visit nodes multiple times?</p>
</blockquote>
<p>nope, get_inlay_hints is non-recursive</p>



<a name="188402949"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/slow%3F/near/188402949" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/slow.3F.html#188402949">(Feb 17 2020 at 19:51)</a>:</h4>
<p><code>get_inlay_hints</code> seems to handle statements, but <code>inlay_hints</code> will visit functions, every statement in a function, and so on</p>



<a name="188403006"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/slow%3F/near/188403006" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kirill Bulatov <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/slow.3F.html#188403006">(Feb 17 2020 at 19:52)</a>:</h4>
<p>Just for a context, after we deal with <a href="https://github.com/rust-analyzer/rust-analyzer/issues/1618" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/issues/1618">https://github.com/rust-analyzer/rust-analyzer/issues/1618</a> , we should be able to throw off the majority of the code there, analyzing the PAT's and a bunch of parent nodes for a few cases only.</p>



<a name="188403328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/slow%3F/near/188403328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/slow.3F.html#188403328">(Feb 17 2020 at 19:58)</a>:</h4>
<p>Ah, I see what you meant. Sorry.</p>



<a name="188824140"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/slow%3F/near/188824140" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Laurențiu <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/slow.3F.html#188824140">(Feb 22 2020 at 16:45)</a>:</h4>
<p><span class="user-mention silent" data-user-id="231447">Kirill Bulatov</span> <a href="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/slow.3F/near/188403006" title="#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/slow.3F/near/188403006">said</a>:</p>
<blockquote>
<p>Just for a context, after we deal with <a href="https://github.com/rust-analyzer/rust-analyzer/issues/1618" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/issues/1618">https://github.com/rust-analyzer/rust-analyzer/issues/1618</a> , we should be able to throw off the majority of the code there, analyzing the PAT's and a bunch of parent nodes for a few cases only.</p>
</blockquote>
<p>So the code can be simplified now?</p>



<a name="188826363"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/185405-t-compiler/rust-analyzer/topic/slow%3F/near/188826363" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Kirill Bulatov <a href="https://rust-lang.github.io/zulip_archive/stream/185405-t-compiler/rust-analyzer/topic/slow.3F.html#188826363">(Feb 22 2020 at 17:44)</a>:</h4>
<p>Yes, hopefully.</p>
<p>I plan to refactor the code as part of <a href="https://github.com/rust-analyzer/rust-analyzer/issues/3273" target="_blank" title="https://github.com/rust-analyzer/rust-analyzer/issues/3273">https://github.com/rust-analyzer/rust-analyzer/issues/3273</a> , if nobody comes with the PR for that before.</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>